package com.hanyxx.thread;

/**
 * @author layman
 * @date 2021/2/4
 */
public class ThreadDemo01 {
    public static void main(String[] args) throws InterruptedException {
        Demo01 demo01 = new Demo01();
        demo01.start();
        for (int i = 0; i < 10; i++) {
            System.out.println(Thread.currentThread().getName()+"--->"+i);
            Thread.sleep(100);
        }
    }
}
class Demo01 extends  Thread{
    @lombok.SneakyThrows
    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            System.out.println(Thread.currentThread().getName()+"--->"+i);
            Thread.sleep(100);
        }
    }
    public synchronized void printString(){
        System.out.println(Thread.currentThread().getName());
    }
}
